package net.zjitc.dao.impl;

import net.zjitc.dao.LoginDao;
import net.zjitc.pojp.AdminUser;
import net.zjitc.service.LoginService;
import net.zjitc.utils.db.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;
import java.util.Queue;

/**
 * Created by Administrator on 2017/11/16.
 */
public class LoginDaoImpl implements LoginDao {
    public AdminUser findByUsernameAndPassWord(String username, String password) {
        QueryRunner runner=new QueryRunner(C3P0Utils.getDataSource());
        String sql="select *from adminuser where username=? and password=?";
        try {
           AdminUser adminUser= (AdminUser) runner.query(sql,new BeanHandler(AdminUser.class),username,password);
        return  adminUser;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
